package com.itheima.mall.service.impl;

import com.itheima.mall.service.OssService;
import com.itheima.mall.template.OssTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

@Service
public class OssServiceImpl implements OssService {

    @Resource
    private OssTemplate ossTemplate;

    /**
     * 图片上传
     */
    @Override
    public String upload(MultipartFile headPho) {
        try {
            //上传到阿里云
            return ossTemplate.upload(headPho.getOriginalFilename(), headPho.getInputStream());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

}
